home *** CD-ROM | disk | FTP | other *** search
/ NeXT Education Software Sampler 1992 Fall / NeXT Education Software Sampler 1992 Fall.iso / Programming / Source / HippoDraw / HippoDrawSrc1.1 / Hippo.subproj / NewInspector.m < prev    next >
Encoding:
Text File  |  1992-04-25  |  3.0 KB  |  156 lines

  1. /* NewInspector.m    by Imran Qureshi    November 1991
  2.  *
  3.  * Copyright (C)  1991  The Board of Trustees of
  4.  * The Leland Stanford Junior University.  All Rights Reserved.
  5.  */
  6.  
  7. #import "NewInspector.h"
  8.  
  9. const char NewInspector_h_rcsid[] = NEWINSPECTOR_H_ID;
  10. const char NewInspector_m_rcsid[] = "$Id: NewInspector.m,v 1.15 1992/04/06 00:38:26 pfkeb Rel $";
  11.  
  12. #import <appkit/Box.h>
  13. #import <appkit/Button.h>
  14. #import <appkit/PopUpList.h>
  15. #import <appkit/Matrix.h>
  16.  
  17. #import "InspectBase.h"
  18.  
  19. @implementation NewInspector
  20.  
  21. static id theInspector = nil;
  22.  
  23. /* makes sure there is only one instantiation of this object */
  24. + new
  25. {
  26.     if (!theInspector) {
  27.         theInspector = self = [super new];
  28.         [self init];
  29.     } else
  30.         self = theInspector;
  31.         
  32.     return self;
  33. }
  34.  
  35. -init
  36. {
  37.     //[super init];
  38.         
  39.     [NXApp loadNibSection:"NewInspector.nib" owner:self
  40.         withNames:NO fromZone:[self zone]];
  41.     ViewsList = [[List allocFromZone:[self zone]] init];
  42.     SupervisorList = [[List allocFromZone:[self zone]] init];
  43.     
  44.     
  45.     thePopUpList = [thePopUpListButton target];
  46.     [thePopUpList setTarget:self];
  47.     [thePopUpList setAction:@selector(toggleInspectorPanels:)];
  48.     [thePopUpList removeItemAt:0];  
  49.     /* IB comes up with atleast one item in the popupList. We do this to get rid of that.*/
  50.     
  51.     return self;
  52. }
  53.  
  54. -inspectorPanel
  55. {
  56.     return InspectorPanel;
  57. }
  58.  
  59. -free
  60. {
  61.     [ViewsList free];
  62.     [SupervisorList free];
  63.     //[InspectorPanel orderOut:self];
  64.     return [super free];
  65. }
  66. - orderFrontPanel:sender
  67. {
  68.     [InspectorPanel setFloatingPanel:YES];
  69.     [InspectorPanel orderFront:self];
  70.     return self;
  71. }
  72. - orderBackPanel:sender
  73. {
  74.     [InspectorPanel orderBack:self];
  75.     return self;
  76. }
  77.  
  78. -setTitle:(char *)theTitle
  79. {
  80.     [InspectorPanel setTitle:theTitle];
  81.     return self;
  82. }
  83. -addView:(id)aView withName:(char *)Name withSupervisor:(id)aSupervisor
  84. {
  85.     [ViewsList addObject:aView];
  86.     [SupervisorList addObject:aSupervisor];
  87.     
  88.     [thePopUpList addItem:Name];
  89.     
  90.     [InspectorBox setContentView:aView];
  91.     [InspectorBox display];
  92.     
  93.     [thePopUpListButton setTitle:Name];
  94.     return self;
  95. }
  96.  
  97. -remove:(char *)Name
  98. {
  99.     int    i;
  100.     
  101.     i = [thePopUpList indexOfItem:Name];
  102.     [thePopUpList removeItemAt:i];
  103.     [ViewsList removeObjectAt:i];
  104.     return self;
  105. }
  106.  
  107. -replace:(char *)Name with:(char *)someName andView:(id)aView
  108. {
  109.     int    i;
  110.     
  111.     i = [thePopUpList indexOfItem:Name];
  112.     
  113.     /* if new name is desired, change the name */
  114.     if (someName) {
  115.         [thePopUpList removeItemAt:i];
  116.         [ thePopUpList insertItem: someName at:i];
  117.     }
  118.     [ViewsList replaceObjectAt:i with:aView];
  119.     return self;
  120. }
  121. -show:(char *)Name
  122. {
  123.     int    i;
  124.     
  125.     i = [thePopUpList indexOfItem:Name];
  126.     [thePopUpListButton setTitle:Name];
  127.     [InspectorBox setContentView:[ViewsList objectAt:i]];
  128.     [InspectorBox display];
  129.     return self;
  130.  
  131. }
  132.  
  133. -updateDisplay
  134. {
  135.     [InspectorBox display];
  136.     return self;
  137. }
  138. - windowDidUpdate:sender
  139. {
  140.     [SupervisorList makeObjectsPerform:@selector(windowDidUpdate:) with:sender];
  141.     return self;
  142. }
  143. -toggleInspectorPanels:sender
  144. {
  145.     int i;
  146.     
  147.     i = [sender selectedRow];
  148.     [[SupervisorList objectAt:i] updateView];
  149.     [InspectorBox setContentView:[ViewsList objectAt:i]];
  150.     [InspectorBox display];
  151.     return self;
  152. }
  153.  
  154.  
  155. @end
  156.